<template>
	<view class="container">
		<u-sticky class="container__sticky"><sticky-drawprize :subsectionList="subsectionList" :drawprize="drawprize" :website="website"></sticky-drawprize></u-sticky>
		
		<view class="container__warpswiper__row__ul box pad" id="yxym" v-for="(item, inx) in list" :key="inx">
			<view class="heads" v-if="item.alias === 'AoMenLiuHeCai'">
				<u--image mode="widthFix" width="100%" height="100%" src="https://res.cloudinary.com/don15jt24/image/upload/v1708583541/amtu_sexar5.jpg"></u--image>
			</view>
			
			<view v-for="(vl, vk) in item.list" :key="vk">
				<!-- 广告 -->
				<view v-if="(vk % 2) == 0">
					<view v-if="Math.ceil((vk/2)) < advs.length">
						<Advertisements :data-list="advs[Math.ceil((vk/2))]"></Advertisements>
					</view>
					<view v-else>
						<Advertisements :data-list="advs[(Math.ceil((vk/2)) % advs.length)]"></Advertisements>
					</view>
				</view>
				<!-- 广告 完 -->
				
				<LinkTuiJian></LinkTuiJian>
				<ItemTpl :data-list="vl" :leftIsShow="leftIsShow" :rightIsShow="rightIsShow" :webname="website.webname"></ItemTpl>
			</view>
			<YouQingTuiJian></YouQingTuiJian>
			<Animals :list="config"></Animals>
			
		</view>
	</view>
</template>

<script>
import { getAdvsListByPos } from '@/api/cms.js';
import { getLotteryList, getDrawprize, getConfig } from '@/api/lottery.js';
import StickyDrawprize from './src/sticky-drawprize.vue';
import ItemTpl from './src/item-tpl.vue';
import LinkTuiJian from './src/lv-se-lian-jie-tui-jian.vue';
import YouQingTuiJian from './src/youqingtuijian.vue';
import Animals from './src/animals.vue';
import Advertisements from './src/advertisements.vue';

export default {
	components: {
		StickyDrawprize,
		ItemTpl,
		LinkTuiJian,
		YouQingTuiJian,
		Animals,
		Advertisements
	},
	data() {
		return {
			title: '瑞气盈门',
			drawprize: [],
			subsectionList: [],
			list: [],
			leftIsShow: true,
			rightIsShow: false,
			config: {},
			website: {},
			advs:[]
		};
	},
	onLoad() {
		this.initConfig();
		this.getDrawprizeInfo();
		this.lotteryList();
		
		this.initAdvsList();
	},
	methods: {
		getDrawprizeInfo() {
			getDrawprize().then(res => {
				if (res.code === 200) {
					this.drawprize = res.data.list;
					this.subsectionList = [];
					this.drawprize.forEach(item => {
						this.subsectionList.push(item.title);
					});
				} else {
					uni.$u.toast(res.message);
				}
			});
		},
		lotteryList() {
			var map = {};
			getLotteryList(map).then(res => {
				if (res.code === 200) {
					this.list = res.data.list;
				} else {
					uni.$u.toast(res.message);
				}
			});
		},
		initConfig() {
			getConfig().then(res => {
				if (res.code === 200) {
					this.config = res.data.config;
					this.website = res.data.website;
				} else {
					uni.$u.toast(res.message);
				}
			});
		},
		initAdvsList(){
			var map = {
				alias : ['ShouYeGuangGao','ShouYeGuangGaoEr']
			};
			getAdvsListByPos(map).then(res => {
				if (res.code === 200) {
					this.advs = res.data.list;
				} else {
					uni.$u.toast(res.message);
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
@import '@/static/css/common.css';
/* #ifndef APP-PLUS */
page {
	width: 100%;
	min-height: 100%;
	display: flex;
}
/* #endif */
.container {
	display: flex;
	flex: 1;
	flex-direction: column;
	// overflow: hidden;
	background-color: #ffffff;
	/* #ifdef MP-ALIPAY || MP-BAIDU */
	height: 100vh;
	/* #endif */
	// margin: 10rpx;
	&__sticky {
		background-color: #ffffff;
		border-bottom: 1px solid #c0c0c0;
		margin-bottom: 10rpx;
		border-bottom-left-radius: 20rpx; /*左上角*/
		border-bottom-right-radius: 20rpx; /*右上角*/
	}
}
</style>
